package com.itheima.health.controller.mobile;

import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.entity.CheckGroup;
import com.itheima.health.pojo.entity.Setmeal;
import com.itheima.health.pojo.result.Result;
import com.itheima.health.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController(value = "mobileSetMealController")
@RequestMapping("/mobile/setmeal")
public class SetMealController {

    @Autowired
    private SetMealService setMealService;

    /**
     * 查询所有套餐
     * @return
     */
    @GetMapping("/getSetmeal")
    public Result getSetmeal() {
        log.info("查询所有套餐");
        List<Setmeal> setmeals = setMealService.getSetmeal();
        return new Result(true, "查询成功", setmeals);
    }

    /**
     * 根据套餐id查询套餐详情
     * @return
     */
    @GetMapping("/findById")
    public Result findById(Integer id) {
        log.info("根据套餐id查询套餐详情:{}",id);
        Setmeal setmeal = setMealService.findById(id);
        return new Result(true, "查询成功", setmeal);
    }
}
